<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class General_model extends MY_Model {

    var $db_select = "class_db";

    function __construct(){
        parent::__construct();
        $this->load->database();
    }

    function table_name(){
        return "general";
    }

    function getListTable() {
        $sql = "SHOW TABLES FROM ". $this->db_select;
        $query = $this->db->query($sql);
        return $this->getValues($query->result_array());
    }
    
    function getListColumnNameByTable($tableName) {
        $sql = "SHOW COLUMNS FROM " . $this->db_select .'.'. $tableName;
        $query = $this->db->query($sql);
        if ($query->num_rows() < 1) {
            return null;
        }
        return $query->result_array();
    }

    function getValues($array) {
        $options = array();
        foreach ($array as $key => $value) {
            $options[$value['Tables_in_class_db']] = $value['Tables_in_class_db'];
        }
        return $options;
    }
}
?>